package com.guigu.tms.commons.order.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.Data;
import org.springframework.util.StringUtils;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 快递员业务范围表
 * </p>
 *
 * @author zwj
 * @since 2022-10-04
 */
@TableName("pd_courier_scop")
@Data
public class CourierScop implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 用户id
     */
    private String userId;

    /**
     * 行政区域id
     */
    private String areaId;

    /**
     * 快递员作业范围
     */
    private String mutiPoints;

    @TableField(exist = false)
    private List<List<Map>> mutiPointList;


    public List<List<Map>> getMutiPointList() {
        if(StringUtils.isEmpty(this.mutiPoints)){
            return null;
        }
        ObjectMapper objectMapper = new ObjectMapper();
        try {
            return objectMapper.readValue(this.mutiPoints,List.class);
        } catch (JsonProcessingException e) {
            e.printStackTrace();
            return null;
        }
    }

    public void setMutiPointList(List<List<Map>> mutiPointList) {
        this.mutiPointList = mutiPointList;
    }

}
